// 基础类型定义
export interface LogEntry {
  createdAt: string;
  message: string;
}

export interface OutputFile {
  id: string;
  name: string;
  type: string;
  size: number;
}

export interface Category {
    id: string;
    name: string;
  }

// 自定义任务类型
export interface CustomTask {
  id: string;
  taskTitle: string;
  taskGuide: string;
  category: string;
  saveToLibrary: boolean;
}

// Task Context 相关类型
export interface Task {
  id: string;
  taskTitle: string;
  taskGuide: string;
  createdAt: Date;
  category: string;
}

export type TaskStatus = 'waiting' | 'running' | 'success' | 'error' ;

export interface TaskContextType {
  tasks: Task[];
  loading: boolean;
  error: string | null;
  fetchTasks: () => Promise<void>;
  addTask: (task: Omit<Task, 'id' | 'createdAt'>) => Promise<void>;
  updateTask: (id: string, task: Partial<Task>) => Promise<void>;
  deleteTask: (id: string) => Promise<void>;
}

// Task History Context 相关类型
export interface ExecutionRecord {
  id: string;
  createdAt: Date;
  taskId: string;
  taskTitle: string;
  taskGuide: string;
  status: 'success' | 'error' | 'waiting';
  category: string;
  duration: string;
  logs: {
    createdAt: string;
    message: string;
  }[];
  outputFiles: OutputFile[];
}

export interface TaskHistoryContextType {
  executionRecords: ExecutionRecord[];
  loading: boolean;
  error: string | null;
  fetchExecutionRecords: () => Promise<void>;
  addExecutionRecord: (record: ExecutionRecord) => Promise<void>;
  updateExecutionRecord: (id: string, record: Partial<ExecutionRecord>) => Promise<void>;
  deleteExecutionRecord: (id: string) => Promise<void>;
}



export interface TaskQueueItem {
  id: string;
  status: 'success' | 'error' | 'waiting' | 'running';
  taskId: string;
  taskTitle: string;
  taskGuide: string;
  priority: 'high' | 'normal' | 'low';
}

export interface TaskResultsProps {
  taskQueue: TaskQueueItem[];
  taskResults: ExecutionRecord[];
  outputFiles: OutputFile[];
  onDownload?: (fileId: string) => Promise<void>;
}

export interface TaskExecutionContextType extends TaskResultsProps {
  loading: boolean;
  error: string | null;
  executionLogs: LogEntry[];
  addToQueue: (task: TaskQueueItem) => void;
  removeFromQueue: (id: string) => void;
  updateTaskStatus: (id: string, status: TaskQueueItem['status']) => void;
  updateTaskPriority: (id: string, priority: TaskQueueItem['priority']) => void;
  addTaskResult: (result: ExecutionRecord) => void;
  addOutputFile: (file: OutputFile) => void;
  clearOutputFile: () => void;
  clearQueue: () => void;
  clearResults: () => void;
  addLog: (message: string) => void;
  createTaskLogger: () => (message: string) => void;
  clearLogs: () => void;
} 